classdef static_policy
    %UNTITLED Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
        plan_in_dense_format=[]; 
    end
    
    methods
        function obj=static_policy(plan_in_dense_format)
            obj.plan_in_dense_format=plan_in_dense_format;
        end
        
%         in general, when instantiated, a policy should choose
%         fired instances at each (t) invoked
%         converts sparse format {[min, type, num] ; ....} to dense format
%         minute { f(i,:)=[0 0 0 0 num 0 0 0 0 0 0]}
%         describe instances to be fired on per minute basis
%         i.e. from
%         plan=...
%                 [1, 1, 4
%                 12, 2, 1
%                 22, 8, 1]
%         to   
%             inst(1,:)=[4  0 0 0 0 0 0 0 0 0 ];
%             ....
%             inst(12,:)=[0 1 0 0 0 0 0 0 0 0 0 ];
%             ....
%             inst(22,:)=[0 0 0  0 0 0 0 0 0 1 ];
%             instance_quantity_to_fire=inst;
%             ......        
        function [instance_quantity_to_fire,instance_quantity_to_destroy]=get_choice_at_time(obj,t)
            default=[0 0 0 0 0 0 0 0 0 0 0];
            % min, type, num
            plan= obj.plan_in_dense_format();  %obj.test_plan();
            ind=find(plan(:,1)==t);
            instance_quantity_to_fire=default;  
            instance_quantity_to_destroy=default;  
            if not(isempty(ind))
                for i=1:size(ind,1)
                    % instance_quantity_to_fire=inst(ind,:);
                    instance_quantity_to_fire = zeros(1,11);                    
                    min=plan(ind(i),1);
                    type=plan(ind(i),2);
                    num=plan(ind(i),3);
                    fire_or_destroy=plan(ind(i),4);  
                    if fire_or_destroy==1
                        instance_quantity_to_fire(type)=num;
                    else
                        instance_quantity_to_destroy(type)=num;
                    end
                end
            end
        end

    end
    
end

